﻿
using Abp.Application.Services.Dto;
using Abp.Web.Models;
using Abp.Web.Mvc.Authorization;
using KDS.Mes.Mes.StorageAlcCodes;
using KDS.Mes.Mes.StorageAlcCodes.Dtos;
using KDS.Mes.Web.Models.StorageAlcCodes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace KDS.Mes.Web.Controllers
{
    public class StorageAlcCodesController : MesControllerBase
    {

        private readonly IStorageAlcCodeAppService _lineAlcCodeAppService;

        public StorageAlcCodesController(IStorageAlcCodeAppService lineAlcCodeAppService)
        {
            _lineAlcCodeAppService = lineAlcCodeAppService;
           
        }

        public  ActionResult Index()
        {
		   var model = new GetStorageAlcCodeInput {FilterText = Request.QueryString["filterText"]};
            return View(model);
        }

        [HttpGet]
        [DontWrapResult]
        public JsonResult GetAllAlcCodesByLineId(int id)
        {
            List<ComboboxItemDto> lst = new List<ComboboxItemDto>();
            NullableIdDto<int> input = new NullableIdDto<int>();
            input.Id = id;
            lst = _lineAlcCodeAppService.GetAllAlcCodesByLineId(input);
            return Json(lst, JsonRequestBehavior.AllowGet);
        }



        /// <summary>
        /// 根据id获取进行编辑或者添加的用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        //[AbpMvcAuthorize(StorageAlcCodeAppPermissions.StorageAlcCode_CreateStorageAlcCode,StorageAlcCodeAppPermissions.StorageAlcCode_EditStorageAlcCode)]
        public async Task<PartialViewResult> CreateOrEditStorageAlcCodeModal(int? id)
        {
		var input=new NullableIdDto<int>{Id=id};
	 
                 var output=    await _lineAlcCodeAppService.GetStorageAlcCodeForEditAsync(input);

				 var viewModel=new CreateOrEditStorageAlcCodeModalViewModel(output);


            return PartialView("_CreateOrEditStorageAlcCodeModal",viewModel);
        }
	 
       
    }
}